import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/home/model/home_modulesModel.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import '../page/home/logic.dart';

class HomeModules extends StatelessWidget {
  HomeModules({super.key});

  final HomeLogic _logic = Get.find<HomeLogic>();

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.only(top: 12),
        child: Obx(() => GridView.builder(
            physics: const NeverScrollableScrollPhysics(),
            itemCount: _logic.modulesList.length,
            shrinkWrap: true,
            gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                //横轴元素个数
                crossAxisCount: 4,
                //子组件宽高长度比例
                childAspectRatio: 1.3),
            itemBuilder: (BuildContext content, int index) {
              HomeModulesModel model = _logic.findModulesInfo(index);
              return InkWell(
                child: Column(
                  children: [
                    Image.asset(
                      MGImage.image(model.image!, type: ImagePathType.home),
                      width: 27,
                    ),
                    SizedBox(height: 7),
                    Text(model.label ?? "")
                  ],
                  mainAxisAlignment: MainAxisAlignment.center,
                ),
                onTap: () {
                  _logic.selectGridViewItem(model);
                },
              );
            })));
  }
}
